package com.maigao.util;

import lombok.experimental.UtilityClass;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @program: maigao
 * @description:
 * @author: yongza
 * @create: 2021-01-14 14:29
 **/
@UtilityClass
public class FileUtil {

    public String read(String fileName) {
        StringBuilder lines = new StringBuilder();
        try (BufferedReader bufferedReader = new BufferedReader(new FileReader(FileUtil.class.getClassLoader().getResource(fileName).getPath()))) {
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                lines.append(line + "\n");
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return lines.toString();
    }

}
